package com.yc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.entity.User;
import com.yc.mapper.UserMapper;
import com.yc.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * InnoDB free: 4096 kB 服务实现类
 * </p>
 *
 * @author ly
 * @since 2022-05-25
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public List< User > login(String name, String password) {
        Map<String,Object> map=new HashMap<>();
        map.put("ucount",name);
        map.put("password",password);
        return userMapper.selectByMap(map);
    }

    @Override
    public List< User > queryByUcount(String ucount) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.like("ucount",ucount);
        return userMapper.selectList(queryWrapper);
    }

    @Override
    public User queryByUid(Integer uid) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("uid",uid);
        return userMapper.selectOne(queryWrapper);
    }
}
